package cn.wolfcode.geomagicstudio.read;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class PropertiesRead implements Read {


    @Override
    public Map<String, String> Read() throws IOException {

        Properties properties = new Properties();
        properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("generator.properties"));

        String domain = properties.getProperty("domain");

        String[] strings = domain.split("\\.");


        String s = strings[strings.length - 1].replaceFirst(Character.toString(strings[strings.length - 1].charAt(0)),
                Character.toString(Character.toLowerCase(strings[strings.length - 1].charAt(0))));

        HashMap<String,String> map = new HashMap<>();

        map.put("%Object%",s);
        map.put("%Class%",strings[strings.length-1]);
        map.put("%packageUrl%",properties.getProperty("packageUrl"));
        map.put("%Model%",strings[strings.length-3]);
        map.put("%test%",properties.getProperty("test"));

        return map;
    }
}
